package com.example.demo.registar;

import com.example.demo.bean.User;
import com.example.demo.service.impl.UserServiceImpl;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

/**
 * @author: zhushl
 * @Date: 2021-05-14 09:35
 * @Description:
 */
public class UserServiceRegistar implements ImportBeanDefinitionRegistrar {

    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {

        BeanDefinitionBuilder us =  BeanDefinitionBuilder.rootBeanDefinition(UserServiceImpl.class);
        us.addConstructorArgValue(new User());
        registry.registerBeanDefinition("userService",us.getBeanDefinition());
    }
}
